import * as step from '@flow-step/step-toolkit'
import fs from 'fs'
import process from 'process'


export async function installOssutil(version: string) {

    let toolName: string = 'ossutil'
    step.info(`Try to install ossutil with version ${version}`)

    const installPath = await step.tool.install(toolName, version)
    if (!fs.existsSync(`${installPath}/ossutil`)) {
        fs.linkSync(`${installPath}/ossutil-${version}`, `${installPath}/ossutil`)
    }
    fs.chmodSync(`${installPath}/ossutil`, 0o755)
    step.addPath(installPath)
}
